﻿@using MealBooking.Core.Models.Dishes;
@model List<DishCategory>
@{
    var categories = Model;    
    <li data-role="fieldcontain">
        <label for="Category_Id">
            Category :
        </label>
        @if (categories != null && categories.Count != 0)
        {
            <select id="Category_Id" name="Category.Id">
                @if (ViewBag.SelectedDishCategoryId != null)
                {
                    string selectedDishCategoryId = ViewBag.SelectedDishCategoryId;
                    var selectedDishCategory = categories.Single(c => selectedDishCategoryId.Equals(c.Id));                
                    <option value="@selectedDishCategory.Id" selected="selected">@selectedDishCategory.Name</option>
                    categories.Remove(selectedDishCategory);
                }
                @foreach (var category in categories)
                {
                    <option value="@category.Id">@category.Name</option>
                }
            </select>
        }
        else
        {
            <label>
                No Dish Category Yet.</label>
        }
    </li>
}
